package net.xiduth.events.button;

import java.util.HashMap;
import java.util.Map;

import net.xiduth.Settings;
import net.xiduth.events.ButtonEvent;
import net.xiduth.events.EventManager;
import net.xiduth.game.player.Player;
import net.xiduth.utils.ChatColors;

/**
 * @author Tyluur <itstyluur@gmail.com>
 * @since 2012-08-07
 */
public class QuestButtonEvent implements ButtonEvent, ChatColors {

	@Override
	public boolean init() {
		return EventManager.register(190, this);
	}

	public enum Quest {

		RECIPE_FOR_DISASTER(87),

		DWARF_CANNON(34);

		private int id;

		Quest(int id) {
			this.id = id;
		}

		private static final Map<Integer, Quest> MAP = new HashMap<Integer, Quest>();

		public static Quest forId(int id) {
			return MAP.get(id);
		}

		static {
			for (Quest quests : Quest.values()) {
				MAP.put(quests.getId(), quests);
			}

		}
		public int getId() {
			return id;
		}
	}

	@Override
	public boolean handle(Player player, int interfaceId, int buttonId,
			int packetId, int slotId, int slotId2) {
		Quest quest = Quest.forId(slotId);
		if (quest == null) {
			if (Settings.DEBUG)
				System.out.println("Check case " + slotId + ": in quests.txt for configuration of this quest.");
			return false;
		}			
	/*	case RECIPE_FOR_DISASTER:
			if (player.getLastRFDWave() != 4) {
				player.getQuestManager().sendQuestInterface("Recipe for Disaster", 
						Settings.SERVER_NAME + " is under attack by a very dangerous fleet of monsters",
						"from an unknown area. We need the help of a brave, strong",
						"civilian to aid us in this task. If you are willing and able,",
						"conversd wie with the Quest Guide at the home area.",
						"A reward be available for those who help.", "", "Requirements",
						"NONE"); 
			} else {
				player.getPackets().sendIComponentText(1245, 13, "<col=FF0000>You have completed this quest!");
			}
			player.getInterfaceManager().sendInterface(1245);
			break; */
		return true;
	} 

}
